<template>
  <view class="container m-b5" v-if="userInfo.user_id > 0">
    <view class="user-head">
      <view class="user-herad">
        <view class="user-pic">
          <!-- <open-data class="user-pic-im" type="userAvatarUrl"></open-data> -->
          <image class="user-pic-im" :src="userInfo.avatarUrl" mode="scaleToFill"></image>
        </view>
        <view>
          <view class="user-her-le">
            <!-- <open-data class="user-admin onelist-hidden" type="userNickName"></open-data> -->
            <view class="user-admin onelist-hidden">
              <text>{{ userInfo.nickName }}</text>
            </view>
            <view>
              <text class="user-her-le-text">{{ userInfo.integral }} 积分</text>
            </view>
          </view>
          <view v-if="dealer.is_dealer" class="user-her-ri">
            <navigator class="go-ti" hover-class="none" url="../dealer/withdraw/apply/apply">
              <view>{{ dealer.words.index.words.referee.value }}：{{ dealer.referee ? dealer.referee.nickName : '平台' }}
                去提现
              </view>
            </navigator>
          </view>
        </view>
      </view>
    </view>

    <view>
      <view class="user-order">
        <view class="user-order-cont dis-flex">
          <view class="flex-box p-r">
            <navigator hover-class="none" url="../order/index?type=all">
              <text class="iconfont icon-form orderListIcon"></text>
              <text class="listCont">全部订单</text>
            </navigator>
          </view>
          <view class="flex-box p-r">
            <navigator hover-class="none" url="../order/index?type=payment">
              <text class="iconfont icon-daifukuan orderListIcon"></text>
              <text class="listCont">待付款</text>
              <text class="user-tag p-a" v-if="orderCount.payment > 0">{{ orderCount.payment }}</text>
            </navigator>
          </view>
          <view class="flex-box p-r">
            <navigator hover-class="none" url="../order/index?type=checking">
              <text class="iconfont icon-daifukuan orderListIcon"></text>
              <text class="listCont">审核中</text>
              <text class="user-tag p-a" v-if="orderCount.checking > 0">{{ orderCount.checking }}</text>
            </navigator>
          </view>
          <view class="flex-box p-r">
            <navigator hover-class="none" url="../order/index?type=delivery">
              <text class="iconfont icon-daifukuan orderListIcon"></text>
              <text class="listCont">待发货</text>
              <text class="user-tag p-a" v-if="orderCount.delivery > 0">{{ orderCount.delivery }}</text>
            </navigator>
          </view>
          <view class="flex-box p-r">
            <navigator hover-class="none" url="../order/index?type=received">
              <text class="iconfont icon-daishouhuo orderListIcon"></text>
              <text class="listCont">待收货</text>
              <text class="user-tag p-a" v-if="orderCount.received > 0">{{ orderCount.received }}</text>
            </navigator>
          </view>
          <view class="flex-box p-r">
            <navigator hover-class="none" url="../order/index?type=comment">
              <text class="iconfont icon-daipingjia orderListIcon"></text>
              <text class="listCont">待评价</text>
              <text class="user-tag p-a" v-if="orderCount.comment > 0">{{ orderCount.comment }}</text>
            </navigator>
          </view>
        </view>
      </view>
    </view>
    <view class="m-top20">
      <!-- 操作列表 -->
      <view class="widget widget__operat clear">
        <view class="operat__item">
          <navigator hover-class="none" url="/pages/address/index">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-map common-icon"></text>
                <text class="user-orderName h4">收货地址</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
        <view class="operat__item">
          <navigator hover-class="none" url="/pages/coupon/coupon">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-lingquan common-icon"></text>
                <text class="user-orderName h4">领券中心</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
        <view class="operat__item operat-bot">
          <navigator hover-class="none" url="/pages/user/coupon/coupon">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-youhuiquan common-icon"></text>
                <text class="user-orderName h4">我的优惠券</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
        <view class="operat__item operat-bot">
          <navigator hover-class="none" url="/pages/user/live/live">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-lingquan common-icon"></text>
                <text class="user-orderName h4">直播中心</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
        <view class="operat__item">
          <navigator hover-class="none" @tap="logoff" url="/images/clean.png">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-delete common-icon"></text>
                <text class="user-orderName h4">退出登录</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
        <view class="operat__item">
          <navigator hover-class="none" url="/pages/user/help">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-help common-icon"></text>
                <text class="user-orderName h4">我的帮助</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
        <view v-if="dealer.is_show" :class="'operat__item ' + (dealer.is_dealer ? 'dealer_is' : '') + '  operat-bot'">
          <navigator hover-class="none" url="../dealer/apply/apply">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-fenxiaozhongxin common-icon"></text>
                <text class="user-orderName h4">成为分销商</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
        <view v-if="dealer.is_show" :class="'operat__item ' + (dealer.is_dealer ? '' : 'dealer_is') + '  operat-bot'">
          <navigator hover-class="none" url="../dealer/team/team">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-renshu common-icon"></text>
                <text class="user-orderName h4">我的团队</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
        <!--     <view class="operat__item">
      <navigator hover-class="none" url="/pages/activity/index">
        <view class="user-order-title dis-flex b-f">
          <view class="flex-box">
          <text class="iconfont icon-help common-icon"></text>
          <text class="user-orderName h4">游戏</text>
          </view>
          <view class="flex-box">
          <view class="user-orderContBox">
            <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
          </view>
          </view>
        </view>
      </navigator>
    </view>-->

        <!-- <view class="operat__item {{dealer.is_dealer ? '' : 'dealer_is'}} ">
       <navigator hover-class="none" url="../dealer/withdraw/list/list">
         <view class="user-order-title dis-flex b-f">
           <view class="flex-box">
           <text class="iconfont icon-kanjia common-icon"></text>
           <text class="user-orderName h4">提现明细</text>
           </view>
           <view class="flex-box">
           <view class="user-orderContBox">
             <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
           </view>
           </view>
         </view>
       </navigator>
     </view>
     -->
        <view v-if="dealer.is_show" :class="'operat__item ' + (dealer.is_dealer ? '' : 'dealer_is') + '  operat-bot'">
          <navigator hover-class="none" url="../dealer/order/order">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-tubiao_liebiaopailie common-icon"></text>
                <text class="user-orderName h4">分销订单</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
        <view v-if="dealer.is_show" :class="'operat__item operat-bot ' + (dealer.is_dealer ? '' : 'dealer_is')">
          <navigator hover-class="none" url="../dealer/qrcode/qrcode">
            <view class="user-order-title dis-flex b-f">
              <view class="flex-box">
                <text class="iconfont icon-erweima common-icon"></text>
                <text class="user-orderName h4">推广二维码</text>
              </view>
              <view class="flex-box">
                <view class="user-orderContBox">
                  <text class="iconfont icon-xiangyoujiantou user-orderJtou"></text>
                </view>
              </view>
            </view>
          </navigator>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
let app = getApp();
export default {
  data() {
    return {
      userInfo: {
        user_id: 0,
        avatarUrl: '',
        nickName: '',
        integral: ''
      },
      orderCount: {
        payment: 0,
        delivery: 0,
        received: 0,
        comment: 0
      },
      isData: false,
      words: {},
      user: {},
      dealer: {
        is_dealer: '',

        words: {
          index: {
            words: {
              referee: {
                value: ''
              }
            }
          }
        },

        referee: false,
        is_show: ''
      }
    };
  }
  /**
   * 生命周期函数--监听页面加载
   */,
  onLoad: function (options) {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    // 获取当前用户信息
    this.getUserDetail();
    // 获取分销商中心数据
    this.getDealerCenter();
  },
  methods: {
    /**
     * 获取当前用户信息
     */
    getUserDetail: function () {
      let token = uni.getStorageSync('token');
      if (!token) {
        uni.navigateTo({
          url: "/pages/login/form/index"
        })

        return;
      }


      let that = this;
      app.globalData._get('index/detail', {}, function (result) {
        that.setData(result.data);
      });
    },

    /**
     * 获取分销商中心数据
     */
    getDealerCenter: function () {
      let that = this;
      app.globalData._get('dealer/center', {}, function (result) {
        let data = result.data;
        data.isData = true;
        // 设置当前页面标题
        that.setData({
          dealer: data
        });
      });
    },

    logoff: function () {

      uni.showModal({
        content: '确定退出？',
        success: function (res) {
          if (res.confirm) {
            uni.removeStorageSync('user_id');
            uni.removeStorageSync('app');
            uni.removeStorageSync('token');
            uni.removeStorageSync('user_info');
            uni.removeStorageSync('extData');
            uni.removeStorageSync('currentPage');
            uni.showToast({
              title: '退出完成',
              icon: 'success',
            });
            uni.switchTab({
              url: '/pages/index/index'
            });
          } else if (res.cancel) {
            console.log('用户点击取消');
          }
        }
      })


    }
  }
};
</script>
<style>
@import './index.css';
</style>
